<?php
class WebMenuItemModel extends Model {
	var $_table = 'web_menuitem';
	
	var $menuitem_id_nak; //INT UNSIGNED NOT NULL AUTO_INCREMENT,
	var $up_id_nr = 0; //INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '上级菜单',
	var $menu_name_sr; //VARCHAR(16) NOT NULL COMMENT '所属菜单',
	var $item_name_sr; //VARCHAR(45) NOT NULL COMMENT '名称',
	var $type_sr; //ENUM('url', 'page', 'cate') NOT NULL COMMENT '类型',
	var $page_id_nr = 0; //INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '相对应的页面ID',
	var $sort_nr = 999; //SMALLINT(4) UNSIGNED NOT NULL DEFAULT 999 COMMENT '排序',
	var $target_sr = '_self'; //ENUM('_blank', '_self', '_top', '_parent') NOT NULL DEFAULT '_self' COMMENT '显示目标',
	var $title_s = ''; //VARCHAR(64) NULL COMMENT '提示',
	var $url_s = ''; //VARCHAR(256) NULL COMMENT '自定义URL',
	

	public function getMenuItems($menu_name) {
		$nodes = $this->where ( array ('menu_name' => $menu_name ) )->sortAsc ( 'sort' )->retrieve ( 'menuitem_id,up_id,item_name,type,page_id,sort,title,target' );
		return $nodes ? $nodes : array ();
	}
	public function getSubItems($menu_name, $up_id) {
		$nodes = $this->where ( array ('menu_name' => $menu_name, 'up_id' => $up_id ) )->sortAsc ( 'sort' )->retrieve ( 'menuitem_id,up_id,menu_name,item_name,type,page_id,sort,title,target,url' );
		return $nodes && count($nodes) > 0 ? $nodes : array ();
	}
}